Imports KanBan.Pgd.Domain.ValueObjects

Namespace Session

    Public Class UserCredentials

        Public Sub New(ByVal id As Guid, ByVal userName As String, ByVal permissions As IList(Of Permission))
            Me.Id = id
            Me.UserName = userName
            Me.Permissions = permissions
        End Sub

        Private _id As Guid
        Public Property Id() As Guid
            Get
                Return _id
            End Get
            Set(ByVal value As Guid)
                _id = value
            End Set
        End Property


        Private _userName As String
        Public Property UserName() As String
            Get
                Return _userName
            End Get
            Set(ByVal value As String)
                _userName = value
            End Set
        End Property

        Private _permissions As IList(Of Permission) = New List(Of Permission)
        Public Property Permissions() As IList(Of Permission)
            Get
                Return _permissions
            End Get
            Set(ByVal value As IList(Of Permission))
                _permissions = value
            End Set
        End Property

        Public Function HasPermission(ByVal permission As String) As Boolean

            Return Me.Permissions.Any(Function(p) p.Name.ToLower() = permission.ToLower())

        End Function

    End Class

End Namespace

